Description: Don't assume MSF offset is always 150 (#439790)
Author: Martin Michlmayr <tbm@cyrius.com>
Last-Update: 2007-10-21
Index: mkcue-1/mkcue.cc
===================================================================
--- mkcue-1.orig/mkcue.cc	2004-10-27 07:20:30.000000000 +0100
+++ mkcue-1/mkcue.cc	2012-11-10 13:34:34.986131069 +0000
@@ -12,6 +12,9 @@
 
 #include "diskid.h"
 
+/* http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=439790 */
+#define MSF_OFFSET 150
+
 void
 DiskId::ReportError(char *err)
 {
@@ -54,16 +57,12 @@
     }
 
     puts("FILE \"dummy.wav\" WAVE");
-    puts("  TRACK 01 AUDIO");
-    puts("    INDEX 01 00:00:00");
 
 #define min(x, y) ((x) < (y) ? (x) : (y))
-    for (track = cdinfo.FirstTrack + 1;
+    for (track = cdinfo.FirstTrack;
          track <= min(trackcount, cdinfo.LastTrack);
          track++) {
-        /* There is frequently (always?) an offset of 150 sectors, so
-         * subtract the first track's offset. */
-        cdinfo.FrameOffset[track] -= cdinfo.FrameOffset[1];
+        cdinfo.FrameOffset[track] -= MSF_OFFSET;
 
         minutes = seconds = sectors = 0;
         sectors = cdinfo.FrameOffset[track] % 75;
@@ -76,6 +75,9 @@
         }
 
         printf("  TRACK %02d AUDIO\n", track);
+        if (track == 1 && cdinfo.FrameOffset[track] > 0) {
+            printf("    INDEX 00 00:00:00\n");
+        }
         printf("    INDEX 01 %02d:%02d:%02d\n", minutes, seconds, sectors);
     }
 
